<?php
/**
 * The Joomla data model as scottlib slObject classes.
 * @author Aaron Collegeman aaroncollegeman.com
 * @version 0.1.1-BETA
 * 
 * Copyright (C)2008 Collegeman.net, LLC.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
 */

/**
 * josMenuLink controls the administrative menus in the back-end, as well as
 * the availability of Menu Item types specific to your custom components.
 * @table(jos_components) 
 */
class josMenuLink extends slObject {
	
	/** @id */
	public $id;
	
	/** @maxLength(50) */
	public $name;
	
	/** @maxLength(255) */
	public $link = '';
	
	/** 
	 * @integer
	 * @fieldName(menuid) 
	 */
	public $menuId = 0;
	
	/** @integer */
	public $parent = 0;
	
	/** 
	 * @maxLength(255)
	 * @fieldName(admin_menu_link) 
	 */
	public $adminMenuLink = '';
	
	/** 
	 * @maxLength(255)
	 * @fieldName(admin_menu_alt) 
	 */
	public $adminMenuAlt = '';
	
	/**
	 * @maxLength(255)
	 * @fieldName(admin_menu_img)
	 */
	public $adminMenuImg = 's/ThemeOffice/component.png';
	
	/** @integer */
	public $ordering = 0;
	
	public $option = '';
	
	/** @boolean */
	public $enabled = 1;
	
	/** @integer */
	public $iscore = 1;
	
	static function deleteAllForComponent($link) {
		$conn = slMySqlConn::instance();
		$parentId = $conn->val(prepare("SELECT id FROM `jos_components` WHERE `option` = ? ORDER BY `ordering` LIMIT 1", $link));
		$conn->execute(prepare("DELETE FROM `jos_components` WHERE `option` = ? OR `parent` = %d", array($link, $parentId)));
	}
	
}